import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue(),

    AutoImport({
      imports: ['vue'],
      dts: "./auto-imports.d.ts",
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
  ],
  server: {
    host: '0.0.0.0',
    port: 3000,
    open: true
  },
  css: {
    devSourcemap: true,
		//css预处理
		preprocessorOptions: {
			scss: {
				/*
          引入var.scss全局预定义变量，
          如果引入多个文件，
          可以使用
          '@import "@/assets/scss/globalVariable1.scss";@import "@/assets/scss/globalVariable2.scss";'
          如果不生效，可以在app.vue中增加 lang="scss"
          这种格式
				 */
				// additionalData: `
        //   @import "@/assets/scss/index.scss";
        // `
			}
		}
	},
  resolve: { //配置文件引入路径别名
    alias: {
      '@': resolve(__dirname, './src')
    },
    extensions: ['.vue', '.json', '.ts']
  },
})
